package net.tbao.order.vo;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 订单确认页
 */

public class OrderConfirmVo {

    /**
     * 收获地址
     */
    @Setter @Getter
    private List<MemberAddressVo> address;

    /**
     * 购物项
     */
    @Setter @Getter
    private List<OrderItemVo> item;

    /**
     * 积分信息
     */
    @Setter @Getter
    private Integer integration;

    @Setter @Getter
    Map<Long,Boolean> stocks;

    /**
     * 订单防重提交
     */
    @Setter @Getter
    private String orderToken;

    public Integer getCount(){
        Integer i=0;
        if(item!=null) {
            for (OrderItemVo items : item) {
                    i+=items.getCount();
            }
    }
       return i;

    }

    /**
     * 订单总额
     */
    public BigDecimal getTotal() {
        BigDecimal sum =new BigDecimal("0");
        if(item!=null) {
            for (OrderItemVo items : item) {
                BigDecimal multiply = items.getPrice().multiply(new BigDecimal(items.getCount().toString()));
                sum= sum.add(multiply);
            }
        }
        return sum;
    }

    /**
     * 应付总额
     */
    public BigDecimal getPayPrice() {
        return getTotal();
    }
}
